//
//  RootViewController.m
//  Eath
//
//  Created by yuhaya on 10/3/14.
//  Copyright (c) 2014 yuhaya. All rights reserved.
//

#import "RootViewController.h"
#import "Tool.h"
#import "NoticeNavViewController.h"
#import "SettingViewController.h"
#import "JxtContentViewController.h"
#import "JxtRootNavController.h"
#import "NoticeViewController.h"
#import "User.h"

@interface RootViewController () <UITabBarControllerDelegate>

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    SettingViewController * setting = [[SettingViewController alloc] init];
    NoticeNavViewController * notice = [[NoticeNavViewController alloc] initWithRootViewController:[[NoticeViewController alloc] init]];
    UIViewController * jxt = [[JxtRootNavController alloc] initWithRootViewController:[[JxtContentViewController alloc] init]];

    self.delegate = self;
    self.viewControllers = @[notice,jxt,setting];
   
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    if([User isLogin]){
        
        return YES;
    }else{
        
        if([viewController isKindOfClass:[NoticeNavViewController class]] || [viewController isKindOfClass:[JxtRootNavController class]]){
            return NO;
        }else{
            return YES;
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
